#ifndef _SEMAPHORE_H_
#define _SEMAPHORE_H_

#include <pthread.h>
/* this code was taken, unmodified from Matthew Alden */

/* Similar to Java, we'll define our own semaphore "class", but in this case
   modeled after the conventions of the pthreads library. */
typedef struct {
	unsigned int count;
	pthread_mutex_t mutex;
	pthread_cond_t cond;
} semaphore_t;

int semaphore_init(semaphore_t* sp, unsigned int count);
int semaphore_destroy(semaphore_t* sp);
int semaphore_down(semaphore_t* sp);
int semaphore_up(semaphore_t* sp);
int semaphore_getCount(const semaphore_t* sp);

#endif
